<template>
	<div class="main_content">
		<div class="top_seach">
			<div class="btns">
				<el-input v-model="input" placeholder="请输入内容" style="margin-right: 10px;" prefix-icon="el-icon-search"
					clearable />
				<el-button type="primary" icon="el-icon-search" @click="handleSearch"></el-button>
				<el-button type="primary" @click="handleSearch1">重置</el-button>
			</div>
		</div>
		<div class="content_table">
			<el-table :data="EvaluateData" style="width: 100%">
				<el-table-column type="selection" width="55">
				</el-table-column>
				<el-table-column label="评论用户" prop="nickname" width="180">
				</el-table-column>
				<el-table-column label="所属农产品" prop="farmName" width="380">
				</el-table-column>
				<el-table-column label="评价内容" prop="content" width="560">
				</el-table-column>
				<el-table-column label="评分" prop="score" width="150">
				</el-table-column>
				<el-table-column label="评论时间" prop="createTime" width="200">
				</el-table-column>
				<el-table-column label="操作" fixed="right" width="180">
					<template slot-scope="scope">
						<el-button size="mini" type="danger"
							@click="handleDelete(scope.$index, scope.row)">删除</el-button>
					</template>
				</el-table-column>
			</el-table>
		</div>
		<div class="footer_page">
			<el-pagination @current-change="handleCurrentChange" :current-page="currentPage" :page-size="pageSize"
				layout="total, prev, pager, next, jumper" :total="total"></el-pagination>
		</div>
	</div>
</template>

<script>
	import evaluateApi from "@/api/farmEvaluate.js"
	export default {
		data() {
			return {
				total: 0,
				pageSize: 10,
				currentPage: 1,
				input: "",
				EvaluateData: [],
			}
		},
		methods: {
			handleDelete(index, row) { //删除点击事件
				this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.DeleteFarmEvaluate(row),
						this.$message({
							type: 'success',
							message: '删除成功!'
						});
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});
			},
			async DeleteFarmEvaluate(row) { //删除
				const res = await evaluateApi.DeleteFarmEvaluate("/znFarmEvaluate/DeleteFarmEvaluate/" + row.id);
				this.getMagEvaluateAll();
			},
			async handleSearch() { //搜索
				this.getMagEvaluateAll();
			},
			handleSearch1(){
				this.input = ""
				this.getMagEvaluateAll();
			},
			async getMagEvaluateAll() { //全部
				const res = await evaluateApi.getMagEvaluateAll("/znFarmEvaluate/getMagEvaluateAll", {
					searchInfo: this.input,
					currentPage: this.currentPage,
					pageSize: this.pageSize
				});
				if (res.code == 200) {
					this.EvaluateData = res.data.records;
					this.total = res.data.total;
				}
			},
			handleCurrentChange(page) {
				this.currentPage = page;
				this.getMagEvaluateAll();
			}
		},
		created() {
			this.getMagEvaluateAll();
		}
	}
</script>

<style lang="scss" scoped>
	.main_content {
		height: 100%;

		.top_seach {
			height: 7%;
			position: relative;

			.btns {
				display: flex;
				position: absolute;
				align-items: center;
				left: 38%;
				
			}
		}

		.content_table {
			height: 83%;

			.demo-table-expand {
				font-size: 0;

			}

			.demo-table-expand label {
				width: 90px;
				color: #99a9bf;
			}

			.demo-table-expand .el-form-item {
				margin-right: 0;
				margin-bottom: 0;
				width: 50%;
			}

			.ImgBox {
				margin: 0 20px 0 20px;
			}

			.InfoBox {}
		}

		.footer_page {
			height: 10%;
			position: relative;

			.el-pagination {
				position: absolute;
				right: 2%;
				bottom: 50%;
				transform: translateY(50%);
			}
		}

	}
</style>